package cn.kyle.light.controller;


import cn.kyle.light.service.EntryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@Slf4j
@RestController
@RequestMapping("/hello")
public class EntryController {

    @Resource
    EntryService entryService;

    @RequestMapping("/run")
    public String testAsync( ) {
        System.out.println("test begin");
        System.out.println("test finished");
        entryService.testAsync();
        return "made it >>>> " ;
    }

    @RequestMapping("/walk")
    public String testWalk( ) {

        return "走起来！ >>>> " ;
    }

    @RequestMapping("/login")
    public String login(@RequestParam("username") String username, @RequestParam("password") String password ) {
        if (username.equals("admin") && password.equals("123456")) {
            return "用户登录成功" ;
        }else{
            return "用户登录失败" ;
        }
    }

    @RequestMapping("/register")
    public String register( @RequestParam("username") String username, @RequestParam("password") String password ) {

        if(username.length()<5){
            return "用户名过短";
        }

        return "用户注册成功" ;
    }

}
